import Mock from "mockjs";
const baseURL="https://interview-api-t.itheima.net"
import {
  DailySuperVoucher,
  DeliveryFeeReduction,
  HighRatingRecommendation,
  MembersSpendDiscount,
} from "@/miscellaneous/NavData";
Mock.mock(/\/api\/getDailySuperVoucher/, 'get', (options) => { 
   const url = new URL(options.url, baseURL)
   const params = new URLSearchParams(url.search)
   const page = parseInt(params.get('page') || 1)
   const pageSize = parseInt(params.get('pageSize') || 3)
   const startIndex=(page-1)*pageSize
   const endIndex=startIndex+pageSize
   const paginatedData=DailySuperVoucher.slice(startIndex,endIndex)
   const result = {
      total:DailySuperVoucher.length,
      data:paginatedData
   } 
   return {
    code: 200,
    data: result,
    message: "获取成功"
   }
});
 Mock.mock(/\/api\/getDeliveryFeeReduction/, 'get', (options) => { 
   const url = new URL(options.url, baseURL)
   const params = new URLSearchParams(url.search)
   const page = parseInt(params.get('page') || 1)
   const pageSize = parseInt(params.get('pageSize') || 3)
   const startIndex=(page-1)*pageSize
   const endIndex=startIndex+pageSize
   const paginatedData=DeliveryFeeReduction.slice(startIndex,endIndex)
   const result = {
      total:DeliveryFeeReduction.length,
      data:paginatedData
   } 
   return {
    code: 200,
    data: result,
    message: "获取成功"
   }
 });
 Mock.mock(/\/api\/getHighRatingRecommendation/, 'get', (options) => { 
   const url = new URL(options.url, baseURL)
   const params = new URLSearchParams(url.search)
   const page = parseInt(params.get('page') || 1)
   const pageSize = parseInt(params.get('pageSize') || 3)
   const startIndex=(page-1)*pageSize
   const endIndex=startIndex+pageSize
   const paginatedData=HighRatingRecommendation.slice(startIndex,endIndex)
   const result = {
      total:HighRatingRecommendation.length,
      data:paginatedData
   } 
   return {
    code: 200,
    data: result,
    message: "获取成功"
   }
 });
 Mock.mock(/\/api\/getMembersSpendDiscount/, 'get', (options) => { 
   const url = new URL(options.url, baseURL)
   const params = new URLSearchParams(url.search)
   const page = parseInt(params.get('page') || 1)
   const pageSize = parseInt(params.get('pageSize') || 3)
   const startIndex=(page-1)*pageSize
   const endIndex=startIndex+pageSize
   const paginatedData=MembersSpendDiscount.slice(startIndex,endIndex)
   const result = {
      total:MembersSpendDiscount.length,
      data:paginatedData
   } 
   return {
    code: 200,
    data: result,
    message: "获取成功"
   }
 });